package com.jinjunhuang.memoryopt;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

/**
 * @author jianjunhuang.me@foxmail.com
 *         create on 2017/11/16.
 */

public class HandlerActivity extends AppCompatActivity {

    private Button startBtn;

    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
//            show();
        }
    };

    private void show() {
        Toast.makeText(HandlerActivity.this, "test", Toast.LENGTH_LONG).show();
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.handler_activity);

        startBtn = findViewById(R.id.start_handler_btn);
        startBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Message message = new Message();
                handler.sendMessageDelayed(message,10000);
//                handler.sendMessage(message);
            }
        });
    }


}
